package generic.swing;

import java.util.List;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Adam Scarr <scarr.adam@gmail.com>
 */
public class List2ComboBoxModelAdapter<Type> extends List2ListModelAdapter<Type> implements ComboBoxModel {
    private Type selected = null;

    public List2ComboBoxModelAdapter(List<Type> list) {
        super(list);
    }

    public void setSelectedItem(Object anItem) {
        for (Type object: list) {
            if (object.equals(anItem)) {
                int index = list.indexOf(anItem);
                selected = object;

                fireContentsChanged(this, index, index);

                break;
            }
        }
    }

    public Object getSelectedItem() {
        return selected;
    }
}
